package com.qianwang.shopmsg.repository.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.qianwang.shopmsg.entity.Course;
import com.qianwang.shopmsg.repository.BaseDao;
import com.qianwang.shopmsg.repository.CourseMsgDao;

@Repository("courseMsgDao")
@SuppressWarnings("unchecked")
public class CourseMsgDaoImpl extends BaseDao implements CourseMsgDao {

	@Override
	public Course loadCourse(long id) {
		return (Course)getSqlMapClientTemplate().queryForObject("Course.loadCourse", id);
	}

	@Override
	public void addCourse(Course course) {
		getSqlMapClientTemplate().insert("Course.addCourse", course);
	}

	@Override
	public void updateCourse(Course course) {
		getSqlMapClientTemplate().update("Course.updateCourse", course);
	}

	@Override
	public List<Course> listCourseInfos(Map<String, Object> param) {
		return (List<Course>)getSqlMapClientTemplate().queryForList("Course.listCourseInfos", param);
	}

	@Override
	public int countCourse(Map<String, Object> param) {
		Integer count = (Integer)getSqlMapClientTemplate().queryForObject("Course.countCourseInfos",param);
		return count == null?0:count;
	}

	@Override
	public void deleteCourseById(long id) {
		getSqlMapClientTemplate().delete("Course.deleteCourseById", id);
	}
	
}
